export default {
	state: {
		loginStatus:false,
		token:null,
		userInfo:{}
	},
	getters: {},
	mutations: {
		// 一旦进入app就执行
		initUser(state){
			let userInfo=uni.getStorageSync('userInfo');
			if(userInfo){
				userInfo=JSON.parse(userInfo);
				state.userInfo=userInfo;
				state.loginStatus=true;
				state.token=userInfo.token;
			}
		},
		//登录后保存用户信息
		login(state,userInfo){
			state.userInfo=userInfo;
			state.loginStatus=true;
			// state.token=userInfo.token;
			uni.setStorageSync('userInfo',JSON.stringify(userInfo));
		},
		//退出登录
		loginOut(state){
			state.userInfo={};
			state.loginStatus=false;
			state.token=null;
			uni.removeStorageSync('userInfo');
		}
		
	},
	actions: {}
}
